package com.MC.MCard.servlet;

import com.MC.MCard.dao.MerchantDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/merchant/delete")
public class MerchantDeleteServlet extends HttpServlet{


    private MerchantDaoImpl merchantDao = new MerchantDaoImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String mid = req.getParameter("mid");
        try {

            int rows = merchantDao.delete(Integer.parseInt( mid ));

            resp.sendRedirect( req.getContextPath() + "/");
        } catch (Exception e) {
            e.printStackTrace();
            resp.sendRedirect("500.html");
        }
    }

}
